﻿// Copyright (c) Inossem. All rights reserved.
// Licensed under the LGPL-3.0 license. See LICENSE file in the project root for full license information.
using DWF.Studio.Custom;
using DWF.Studio.ISerivces;
using DWF.Studio.Services;
using DWF.Studio.Share.Utils;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace DWF.Studio.Views
{
    /// <summary>
    /// AboutWindow.xaml 的交互逻辑
    /// </summary>
    public partial class WindowAbout
    {
        private IConfigService _configService = null;
        public WindowAbout()
        {
            InitializeComponent();

            if (!DesignerProperties.GetIsInDesignMode(this))
            {
                init();
            }
        }

        private void init()
        {
            _configService = new ConfigService();
            this.tbkProductName.Text = AssemblyInfoHelper.AssemblyProduct;
            this.tbProductName.Text = AssemblyInfoHelper.AssemblyProduct;
            this.tbkProductVersion.Text = new Version(AssemblyInfoHelper.AssemblyVersion).ToString(3);
            this.tbkProductCopy.Text = AssemblyInfoHelper.AssemblyCopyright;

            var config = _configService.LoadAppConfig();
            this.hylkEMail.Inlines.Add(config?.OfficialEMail);
            this.hylkWebsite.Inlines.Add(config?.ProcessgoWebsite);
            this.tbkContact.Text = config?.ContactNumber;
        }

        private void BtnClose_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }

        private void Email_Click(object sender, RoutedEventArgs e)
        {
            var config = _configService.LoadAppConfig();
            if (!String.IsNullOrWhiteSpace(config.OfficialEMail))
            {
                System.Diagnostics.Process.Start($"mailto:{config.OfficialEMail}");
            }
        }

        private void Link_Click(object sender, RoutedEventArgs e)
        {
            var config = _configService.LoadAppConfig();
            if (!String.IsNullOrWhiteSpace(config.ProcessgoWebsite))
            {
                System.Diagnostics.Process.Start(config.ProcessgoWebsite);
            }
        }
    }
}
